import draw.*;
import geometry.Posn;
import geometry.*;
import tester.*;
import java.util.*;
import colors.*;

class Mfmwg{
  Posn location;
  int fuel;
  int rad = 10;
  
  //draws a maaaaagical genie, in a flying saucer machine.
  boolean drawMfmwg(Canvas c){
    return c.drawDisk(this.location, this.rad, new Red());
  }
  
  //the genie has caught a star! fuel++.
  Mfmwg catchStar(Star s){
    return new Mfmwg(this.location, this.fuel + s.span);
  }
  
  // produce a Mfmwg heading in the direction given by the key
  Mfmwg onKeyEvent(String ke){
    if (ke.equals("up")){
      return new Mfmwg(new Posn(this.location.x, this.location.y - 10),
                        this.fuel); 
    } else {if (ke.equals("down")){
      return new Mfmwg(new Posn(this.location.x, this.location.y + 10),
                        this.fuel); 
    } else {if (ke.equals("left")){
      return new Mfmwg(new Posn(this.location.x - 10, this.location.y),
                        this.fuel);
    } else {if (ke.equals("right")){
      return new Mfmwg(new Posn(this.location.x + 10, this.location.y),
                        this.fuel);
    } else{
      return this;      
    }}}}
  }
  
  //adjusts the current ship according to the ticker
  Mfmwg onTick(){
    return new Mfmwg(this.location, this.fuel - 5);
  }
  
  Mfmwg(Posn location, int fuel) {
    this.location = location;
    this.fuel = fuel;
  }
   /*
TEMPLATE:
   FIELDS:
    ... this.fuel ...           --int
    ... this.location ...       --Posn
    ... this.rad ...            --int

    METHODS:
    ... this.drawMfmwg(Canvas c) ...  -- boolean
    ... this.catchStar() ...          -- Mfmwg
    ... this.onKeyEvent(String ke) ...-- Mfmwg
    ... this.onTick() ...             -- Mfmwg

    METHODS FOR FIELDS:
    n/a
*/ 
}